import Vue from "vue";
import Router from "vue-router";

import Home from "@/views/main/home/Home.vue"
import User from "@/views/main/user/User.vue"
import Mall from "@/views/main/mall/Mall.vue"
import PageOne from "@/views/main/other/PageOne.vue"
import PageTwo from "@/views/main/other/PageTwo.vue"

import Main from "@/views/main/Main.vue"


Vue.use(Router)

const router = new Router({
    mode: 'history',
    routes: [
        {
            path: '/',
            component: Main,
            redirect:"home",
            children: [
                { path: "home",name:'home', component: Home },
                { path: "user",name:'user', component: User },
                { path: "mall",name:'mall', component: Mall },
                { path: "page1",name:'page1', component: PageOne },
                { path: "page2",name:'page2', component: PageTwo },
            ]
        },

    ]
})

//解决vue2路由跳转自身报错
const VueRouterPush = Router.prototype.push
Router.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}
export default router